import path from 'path'
import windowUtil from './window-util'
import { Tray, Menu, app } from 'electron'

export function createTray(): void {
  const tray = new Tray(path.join(__dirname, '../../resources/icon.png'))

  const contextMenu = Menu.buildFromTemplate([
    {
      label: '退出',
      type: 'normal',
      click(): void {
        app.exit(0)
      }
    }
  ])

  tray.setToolTip('自定义压缩软件')
  tray.setContextMenu(contextMenu)

  tray.on('click', () => {
    windowUtil.wins['main'].show()
  })
}
